<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\EduMenu;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EduMenuSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Edu Menus';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="edu-menu-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('Create Edu Menu', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
//            'title',
            [
                'attribute' => 'title',
                'enableSorting' => false,
            ],
            [
                'attribute' => 'icon',
                'enableSorting' => false,
                'format' => ['image', [
                    'width' => '80',
                    'height' => '80',
                ]],
//                'value' => function ($model) {
//                    if ($model->icon) {
//                        return Yii::$app->params['localUrl'] . $model->icon;
//                    }
//                    return $model->icon;
//                }
            ],
            [
                'attribute' => 'sort',
//                'enableSorting' => false,
            ],
            [
                'attribute' => 'style',
                'enableSorting' => false,
                'value' => 'styleValue',
                'filter' => EduMenu::attributeValue()['style']
            ],
            [
                'attribute' => 'status',
                'enableSorting' => false,
                'value' => 'statusValue',
//                'value' => function ($model) {
//                    return EduMenu::dropDown('isEnable', $model->status);
//                },
                'filter' => EduMenu::dropDown('isEnable'),
            ],
            //'url:url',
            //'des',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
<?php
$script = <<< JS
    $(".pagination").append('&nbsp;跳转<input id="invalue" type="text" style="border-radius: 5px;outline: none;border: solid 1px #dddddd;width: 52px;height: 34px;text-align: center;" class="pane"/>页&nbsp;<button id="skip" class="btn btn-default skip ok"">确定</button>');
    
    $('#skip').click(function() {
        var page = $('#invalue').val();
        location.href = "index.php?r=edu-menu/index&page="+ page;
    });
JS;
$this->registerJs($script);
?>
